package com.community.charge.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.community.charge.mapper.MeterReadingRecordsMapper;
import com.community.charge.domain.MeterReadingRecords;
import com.community.charge.service.IMeterReadingRecordsService;

@Service
public class MeterReadingRecordsServiceImpl implements IMeterReadingRecordsService {

    @Autowired
    private MeterReadingRecordsMapper meterReadingRecordsMapper;

    @Override
    public MeterReadingRecords selectMeterReadingRecordsById(Long id) {
        return meterReadingRecordsMapper.selectMeterReadingRecordsById(id);
    }

    @Override
    public List<MeterReadingRecords> selectMeterReadingRecordsList(MeterReadingRecords meterReadingRecords) {
        return meterReadingRecordsMapper.selectMeterReadingRecordsList(meterReadingRecords);
    }

    @Override
    public int insertMeterReadingRecords(MeterReadingRecords meterReadingRecords) {
        return meterReadingRecordsMapper.insertMeterReadingRecords(meterReadingRecords);
    }

    @Override
    public int updateMeterReadingRecords(MeterReadingRecords meterReadingRecords) {
        return meterReadingRecordsMapper.updateMeterReadingRecords(meterReadingRecords);
    }

    @Override
    public int deleteMeterReadingRecordsByIds(Long[] ids) {
        int i = meterReadingRecordsMapper.checkCanDeleteByIds(ids);
        if (i > 0) {
            throw new RuntimeException("不能删除未支付的订单！！！");
        }
        return meterReadingRecordsMapper.deleteMeterReadingRecordsByIds(ids);
    }

    @Override
    public int deleteMeterReadingRecordsById(Long id) {
        //删除前检查状态
        int i = meterReadingRecordsMapper.checkCanDelete(id);
        if (i == 0) {
            throw new RuntimeException("不能删除未支付的订单！！！");
        }
        return meterReadingRecordsMapper.deleteMeterReadingRecordsById(id);
    }

}
